cssselector: Don't invoke undefined behavior
authorMatthias Clasen <mclasen@redhat.com>
Fri, 26 Feb 2016 19:48:21 +0000 (14:48 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 26 Feb 2016 20:52:19 +0000 (15:52 -0500)
Avoid undefined behavior in the calculation of some
hash values. Found by gcc's undefined behavior sanitizer.

gtk/gtkcssselector.c

index f0e91b2a5cf059fe972d6823faea3b5f436a9605..9309de5d6fd59542cef74c5267e47ec32428bb97 100644 (file)
@@ -842,7 +842,7 @@ match_pseudoclass_position (const GtkCssSelector *selector,
 static guint
 hash_pseudoclass_position (const GtkCssSelector *a)
 {
-  return (((a->position.type << POSITION_NUMBER_BITS) | a->position.a) << POSITION_NUMBER_BITS) | a->position.b;
+  return (guint)(((((gulong)a->position.type) << POSITION_NUMBER_BITS) | a->position.a) << POSITION_NUMBER_BITS) | a->position.b;
 }
 
 static int